package com.work.service.impl;

import com.work.bean.Class;
import com.work.bean.Student;
import com.work.dao.ClassDao;
import com.work.dao.StudentDao;
import com.work.dao.impl.ClassDaoImpl;
import com.work.dao.impl.StudentDaoImpl;
import com.work.dto.StudentClass;
import com.work.service.ClassService;

import java.util.List;

public class ClassServiceImpl implements ClassService {
    ClassDao classDao = new ClassDaoImpl();
    StudentDao studentDao = new StudentDaoImpl();
    public List<Class> queryClass() {
        return classDao.queryClass();
    }

    public Class queryClassById(Integer id) {
        return classDao.queryClassById(id);
    }

    @Override
    public StudentClass query(Student student) {
        Student student1 = studentDao.queryStudentById(student.getId());
        Class c = classDao.queryClassById(student1.getClass_id());
        StudentClass studentClass = new StudentClass(student1.getId(),student1.getuId(),student1.getsNo(),student1.getSname(),student1.getAge(),student1.getEmail(),student1.getQq(),student1.getClass_id(),c.getCname());
        return studentClass;
    }

    public int saveClass(Class c) {
        return classDao.saveClass(c);
    }

    public int updateClass(Class c) {
        return classDao.updateClass(c);
    }

    public int deleteClass(Integer id) {
        return classDao.deleteClass(id);
    }
}
